﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RPGGameServer.Cache
{
    public class CacheManager
    {
        //存储所有类型的缓存
        private readonly static Dictionary<Type, ICache> dicBizs = new Dictionary<Type, ICache>();

        static CacheManager()
        {
            //添加所有类型的缓存
            Add<AccountCache>();
        }

        public static void Add<T>() where T: ICache, new()
        {
            dicBizs.Add(typeof(T), new T());

        }

        public static T Get<T>()where T: class, ICache
        {
            ICache cache;
            if (dicBizs.TryGetValue(typeof(T), out cache))
            {
                return cache as T;
            }
            return null;
        }

    }
}
